from selenium import webdriver
from time import sleep # 强制等待
# from selenium.webdriver.common.by import By   定位操作
# from selenium.webdriver.common.keys import Keys   键盘操作
# from selenium.webdriver.common.action_chains import ActionChains    鼠标操作
# from selenium.webdriver.chrome.options import Options    配置文件
# from selenium.webdriver.common.action_chains import ActionChains   鼠标操作
from selenium.webdriver.chrome.options import Options  # 配置文件

from selenium.webdriver.common.keys import Keys   # 键盘操作
from selenium.webdriver.common.by import By       # 定位方式
from selenium.webdriver.common.action_chains import ActionChains  # 鼠标操作
from selenium.webdriver.support.select import Select   # 下拉框
from selenium.webdriver.support import expected_conditions as EC   # 判断元素是否存在/可见
from selenium.webdriver.support.wait import WebDriverWait   # 显示等待
driver=webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(10)
driver.get('https://www.baidu.com/')
input_kw=(By.ID,"kw")
#sleep()  强制等待
# driver.implicitly_wait()  隐式等待
#   WebDriverWait    显示等待
# until   直到
# expected_conditions.visibility_of_element_located(元组)  判断元素是否可见
# WebDriverWait(driver,10,1).until(EC.visibility_of_element_located(input_kw))
WebDriverWait(driver,5,1).until(EC.visibility_of_element_located((By.ID,"kw")))
driver.find_element(*input_kw).send_keys("软件测试")
# driver.find_element(By.ID,"kw").send_keys("测试")

# WebDriverWait(driver,5,1).until(EC.visibility_of_element_located((By.ID,"kw")))

sleep(2)
driver.quit()